package com.bensonbasement.snorflux.client;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JToolBar;

import com.bensonbasement.snorflux.client.states.CommandSelectState;
import com.bensonbasement.snorflux.commands.ItemData;
import com.bensonbasement.snorflux.commands.VerbInfo;

public class ItemPanel extends JPanel {
	
	public ItemPanel(ItemData item, int currentAP, CommandSelectState callback) {
		setLayout(new BoxLayout(this,BoxLayout.X_AXIS));
		
		ImageWarehouse warehouse = ImageWarehouse.getInstance();
		
		ImageIcon icon = new ImageIcon(warehouse.getImage(item.getGlyph()));
		// TODO: This space is a dirty trick:
		JLabel label = new JLabel(item.getName()+" ",icon,JLabel.LEADING);
		label.setToolTipText(item.getName());
		
		JToolBar toolBar = new JToolBar();
		toolBar.setFloatable(false);
		for (VerbInfo verb : item.getVerbs()) {
			VerbButton button = new VerbButton(verb,currentAP,callback);
			toolBar.add(button);
		}
		
		this.add(label);
		this.add(Box.createHorizontalGlue());
		this.add(toolBar);
	}
}
